
const testLogin = (req, res, next) => {
    const { username, password } = req.body

    if (!username || !password) next(4)

    if (username.length <= 5 || username.length >= 12 || password.length <= 5 || password.length >= 12) return next()

    next()
}
const testId = (req, res, next) => {
    const id = req.params.id || req.body.id
    // 判断不符合规则
    if (id.length !== 24) return next(5)


    next()
}
const testAdd = (req, res, next) => {
    if(req.file){

        const avatar = '/public/avatar/' + req.file.filename
        
        req.body.avatar = avatar
    }


    next()

}
module.exports = {
    testLogin,
    testId,
    testAdd
}